from django.shortcuts import render

# Create your views here.
from rest_framework.generics import CreateAPIView
from rest_framework.response import Response
from rest_framework.views import APIView

from users.serializers import RegisterCreateSerializer
from .models import User


class RegisterUsernameAPIView(APIView):

    def get(self,request,username):
        count = User.objects.filter(username=username).count()

        context = {
            'count':count,
            'username':username
        }

        return Response(context)

class RegisterPhoneCountAPIview(APIView):

    def get(self,request,mobile):

        count = User.objects.filter(mobile=mobile).count()

        context = {
            'count':count,
            'phone':mobile
        }

        return Response(context)

class RegisterCreateView(CreateAPIView):


    serializer_class = RegisterCreateSerializer